<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
</html>
<script>
    //发送一个ajax请求，需要4步
    //1.创建一个xhr对象
    var xhr=new XMLHttpRequest()

    //2.配置xhr对象
xhr.open('get','./data.json')

    //3.设置回调函数，用来接收返回的响应数据
    xhr.onreadystatechange=function(){
if (xhr.readyState==4) {
    console.log('得到了数据',JSON.parse(xhr.responseText));
    
}
    }   
     //4.发送请求
     xhr.send()
</script>